import 'package:dynamic_forms/dynamic_forms.dart';
import 'package:flutter_dk_form/src/dy_components/form_field_list_item/form_field_list_item.dart';

import 'form_field_list_item.dart';

class FormFieldListItemParser extends ElementParser<DyFormFieldListItem> {
  @override
  String get name => "formFieldListItem";

  @override
  DyFormFieldListItem parse(
      ParserNode parserNode, FormElement parent, ElementParserFunction parser) {
    var formFieldListItem = DyFormFieldListItem();
    formFieldListItem.fillFormFieldListItem(
      id: parserNode.getPlainStringValue("id"),
      isVisible: parserNode.getIsVisible(),
      parent: parserNode.getParentValue(parent),
      children: parserNode.getChildren<FormElement>(
          parent: formFieldListItem,
          parser: parser,
          childrenPropertyName: DyFormFieldListItem.childrenPropertyName,
          isContentProperty: true),
    );
    return formFieldListItem;
  }
}